<!--{include control/admin/tpl/admin_header}-->  
<div class="page_title">
	<h1>{$_lang['rule_manage']}</h1>
 	<div class="tool"> 
          <a href="{BASE_URL}/index.php/admin/user_mark">{$_lang['credit_rules_manage']}</a>
   		  <a href="{BASE_URL}/index.php/admin/user_mark/add" class="here">{if $mark_rule_id}{$_lang['edit_credit_rules']}{else}{$_lang['add_credit_rules']}{/if}</a>
	</div>
</div>
<div class="box post">
       <form action="{BASE_URL}/index.php/admin/user_mark/save" method="post" name="frm1" id="frm1" enctype="multipart/form-data">
       	   <input type="hidden" id="hdn_mark_rule_id" name="hdn_mark_rule_id" value="{$mark_rule_arr['mark_rule_id']}">
       	   <input type="hidden" name="formhash" value="{FORMHASH}"> 
            <table class="detail" width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <th scope="row" width="200">{$_lang['credit_value']}{$_lang['zh_mh']}</th>
                <td><input name="txt_g_value" type="text" value="{$mark_rule_arr['g_value']}" class="txt" style=" width:260px;" />
			  </td>
              </tr>
			  <tr>
                <th scope="row" width="200">{$_lang['ability_value']}{$_lang['zh_mh']}</th>
                <td><input name="txt_m_value" type="text" value="{$mark_rule_arr['m_value']}" class="txt" style=" width:260px;" />
			  </td>
              </tr>
             <tr>
                <th scope="row">{$_lang['employer_name']}{$_lang['zh_mh']}</th>
                <td> <input name="txt_g_title" type="text" value="{$mark_rule_arr['g_title']}" class="txt" style=" width:260px;" /></td>
              </tr>
			  
			  <tr>
                <th scope="row">{$_lang['witkey_name']}{$_lang['zh_mh']}</th>
                <td> <input name="txt_m_title" type="text" value="{$mark_rule_arr['m_title']}" class="txt" style=" width:260px;" /></td>
              </tr>
			  <tr>
               <th scope="row">{$_lang['employer_icon']}{$_lang['zh_mh']}</th>
                <td> 
				<input type="hidden" name="hdn_g_ico" id="hdn_g_ico" value="$mark_rule_arr['g_ico']">
				<input type="hidden" name="hdn_g_ico_fid" id="hdn_g_ico_fid" value="{$g_fid}" />
				<input type="file" name="g_ico" id="g_ico" ext=".png,.jpg,.jpeg,.gif" class="file">
				<button type="button"  onclick="upload('g_ico');" class="pill">{$_lang['upload']}</button>
				<span id="span_g_ico">
					{if $mark_rule_arr['g_ico']}
					<img src="{BASE_URL}/{$mark_rule_arr['g_ico']}" onload="resize(this)" />
					<a href="javascript:;" onclick="return del_file('hdn_g_ico','span_g_ico')">$_lang['delete']</a>
					{/if}
				</span>
				</td>
              </tr>
			  <tr>
                <th scope="row">{$_lang['witkey_icon']}{$_lang['zh_mh']}</th>
                <td> 
				<input type="hidden" name="hdn_m_ico" id="hdn_m_ico" value="$mark_rule_arr['m_ico']">
				<input type="hidden" name="hdn_m_ico_fid" id="hdn_m_ico_fid" value="{$m_fid}" />
				<input type="file" name="m_ico" id="m_ico" ext=".png,.jpg,.jpeg,.gif" class="file">
				<button type="button"  onclick="upload('m_ico');" class="pill">{$_lang['upload']}</button>
				<span id="span_m_ico">
					{if $mark_rule_arr['m_ico']}
					<img src="{BASE_URL}/{$mark_rule_arr['m_ico']}" onload="resize(this)" />
					<a href="javascript:;" onclick="return del_file('hdn_m_ico','span_m_ico')">$_lang['delete']</a>
					{/if}
				</span>
				</td>
              </tr>
              <tr>
                <th scope="row">&nbsp;</th>
                <td>
                	<div class="clearfix padt10">
                    <button class="positive pill primary button" type="submit" 
					onclick="return checkForm(document.getElementById('frm1'),false);"
					 value={$_lang['submit']}>
                    	{$_lang['submit']}</button>
                    <button class="pill button" type="button" onclick="to_back();" value={$_lang['return']}><span class="uparrow icon"></span>{$_lang['return']}</button>
                	</div>
                </td>
              </tr>
            </table>
       </form>
	</div>
<script type="text/javascript" src="{BASE_URL}/static/js/system/ajaxfileupload.js"></script>
<script type="text/javascript">
    function upload(id){
		var o  = document.getElementById(id);
		if(!isExtName(o)){
			art.dialog.alert("{$_lang['file_format_error']}");
			return false;
		}else{
			var mark_rule_id = '$mark_rule_id';
        $.ajaxFileUpload({
            url: '{BASE_URL}/index.php/ajax/upload?file_name='+id+'&file_type=att&obj_id='+mark_rule_id,
            fileElementId: id,
            dataType: 'json',
            success: function(json){ 
                if (json.err) {
                    art.dialog.alert("{$_lang['upload_fail_file_too_large']}"+ json.err);
                }else {
                    var hf = $("#hdn_"+id);
                    var hf_fid = $("#hdn_"+id+"_fid");
                    $(hf).val(json.msg.up_file+'?fid='+json.fid);
                    $(hf_fid).val(json.fid);
					$("#span_"+id).html("<img src='{BASE_URL}/"+json.msg.up_file+"' onload='resize(this)' />").append("<a href=';' onclick='return del_file(\"hdn_"+id+"\",\"span_"+id+"\")'>{$_lang['delete']}</a>");
                }
            },
            error: function(json, status, e){
                if(e){
					art.dialog.alert(e);	
				}
            }
        });
		}
    }
    function resize(img){
    	var h=img.height, w=img.width;
    	if(h>20){
    		img.height=80;
    	}
    	if(w>70){
    		img.width=80;
    	}
    }
	function del_file(file_path,span){
		var value = $("#"+file_path).val().split("?")['0'];
		var fid=$("#"+file_path+"_fid").val();
		var url  = '{BASE_URL}/index.php/admin/user_mark/del_img?filepath='+value+'&fid='+fid+'&pk='+$("#hdn_mark_rule_id").val();
				$.post(url,function(json){
					if(json.status==1){ 
						 $("#"+file_path).val("");
						 $("#"+span).children().remove();
					}
				},'json');
		return false;
	}
</script>
<!--{include control/admin/tpl/admin_footer}-->
